package com.ganlinux.pangoo.controller.restful.user;

import com.alibaba.fastjson.JSON;
import com.ganlinux.pangoo.controller.restful.base.BaseController;
import com.ganlinux.pangoo.dao.model.User;
import com.ganlinux.pangoo.entity.request.ReqLogin;
import com.jfinal.aop.Before;
import com.jfinal.kit.HttpKit;

/**
 * BlogController
 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
 */
//@Before(LoginInterceptor.class)
public class LoginController extends BaseController {

	public void save() {
//		String jsonString=(String) getRequest().getParameterMap().keySet().toArray()[0];
		/*ReqLogin reqVerifyCode = JsonUtil.fromJson(jsonString, ReqLogin.class);
		String username = reqVerifyCode.getPhone();
		String usercode = reqVerifyCode.getCode();*/
		String jsonString=HttpKit.readData(getRequest());
		ReqLogin reqLogin = JSON.parseObject(jsonString, ReqLogin.class);
		reqLogin.setReqHeader(getHeaderFromRequest(getRequest()));
		renderText(JSON.toJSONString(User.dao.login(reqLogin)));
	}
	
}


